package online.hxstart.code.concurrent.chapter03;

import java.util.stream.IntStream;

/**
 * @author huxing
 * @date 19-4-23 星期二 下午3:55
 * @describe
 */
public class ThreadYield {

  public static void main(String[] args) {
    IntStream.range(0, 2).mapToObj(ThreadYield::create).forEach(Thread::start);
  }

  private static Thread create(int inex) {
    return new Thread(
        () -> {
          if (inex == 0) {
            Thread.yield();
          }
          System.out.println(inex);
        });
  }
}
